package cn.iocoder.yudao.module.shop.convert.store;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;

import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.shop.controller.admin.store.vo.*;
import cn.iocoder.yudao.module.shop.dal.dataobject.store.StoreDO;

/**
 * 库存 Convert
 *
 * @author 曹建伟
 */
@Mapper
public interface StoreConvert {

    StoreConvert INSTANCE = Mappers.getMapper(StoreConvert.class);

    StoreDO convert(StoreCreateReqVO bean);

    StoreDO convert(StoreUpdateReqVO bean);

    default StoreDO convert(StoreDO storeDO, StoreNumReqVO bean){
        if(bean == null) {
            return null;
        }

        StoreDO.StoreDOBuilder xstoreDO = StoreDO.builder();

        xstoreDO.id( bean.getId() );
        xstoreDO.num( bean.getNum() + storeDO.getNum() );

        return xstoreDO.build();
    }

    default StoreDO convert(StoreDO storeDO, Integer changeNum) {
        StoreDO.StoreDOBuilder xstoreDO = StoreDO.builder();

        xstoreDO.id( storeDO.getId() );
        xstoreDO.num( changeNum + storeDO.getNum() );

        return xstoreDO.build();
    }

    StoreRespVO convert(StoreDO bean);

    List<StoreRespVO> convertList(List<StoreDO> list);

    PageResult<StoreRespVO> convertPage(PageResult<StoreDO> page);

    List<StoreExcelVO> convertList02(List<StoreDO> list);

}
